//
//  XLFileListModel.m
//  XLConversationInputView
//
//  Created by ilongge on 2022/8/10.
//

#import "XLFileListModel.h"

@implementation XLFileListModel
- (instancetype)initWith:(NSDictionary *)model {
    if (self = [super init]) {
        _fileExtendedAttributes = model[@"NSFileExtendedAttributes"];
        _fileExtension = [model[@"NSFileExtension"] description];
        _fileExtensionHidden = [model[@"NSFileExtensionHidden"] description];
        _fileGroupOwnerAccountID = [model[@"NSFileGroupOwnerAccountID"] description];
        _fileGroupOwnerAccountName = [model[@"NSFileGroupOwnerAccountName"] description];
        _fileName = [model[@"NSFileName"] description];
        _fileOwnerAccountID = [model[@"NSFileOwnerAccountID"] description];
        _filePath = [model[@"NSFilePath"] description];
        _filePosixPermissions = [model[@"NSFilePosixPermissions"] description];
        _fileReferenceCount = [model[@"NSFileReferenceCount"] description];
        _fileSize = [model[@"NSFileSize"] description];
        _fileSystemFileNumber = [model[@"NSFileSystemFileNumber"] description];
        _fileSystemNumber = [model[@"NSFileSystemNumber"] description];
        _fileType = [model[@"NSFileType"] description];
        NSDate *creationDate = model[@"NSFileCreationDate"];
        NSDate *modificationDate = model[@"NSFileModificationDate"];
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        dateFormatter.dateFormat = @"yyyy-MM-dd HH:mm:ss";
        dateFormatter.timeZone = [NSTimeZone timeZoneWithName:@"Asia/Shanghai"];
        _fileCreationDate = [dateFormatter stringFromDate:creationDate];
        _fileModificationDate = [dateFormatter stringFromDate:modificationDate]; 
    }
    return self;
}

- (NSDictionary *)convertToDictory {
    NSMutableDictionary *dictory = [NSMutableDictionary dictionary];
    dictory[@"NSFileExtendedAttributes"] = _fileExtendedAttributes;
    dictory[@"NSFileExtension"] = _fileExtension;
    dictory[@"NSFileExtensionHidden"] = _fileExtensionHidden;
    dictory[@"NSFileGroupOwnerAccountID"] = _fileGroupOwnerAccountID;
    dictory[@"NSFileGroupOwnerAccountName"] = _fileGroupOwnerAccountName;
    dictory[@"NSFileName"] = _fileName;
    dictory[@"NSFileOwnerAccountID"] = _fileOwnerAccountID;
    dictory[@"NSFilePath"] = _filePath;
    dictory[@"NSFilePosixPermissions"] = _filePosixPermissions;
    dictory[@"NSFileReferenceCount"] = _fileReferenceCount;
    dictory[@"NSFileSize"] = _fileSize;
    dictory[@"NSFileSystemFileNumber"] = _fileSystemFileNumber;
    dictory[@"NSFileSystemNumber"] = _fileSystemNumber;
    dictory[@"NSFileType"] = _fileType;
    dictory[@"NSFileCreationShanghaiDate"] = _fileCreationDate;
    dictory[@"NSFileModificationShanghaiDate"] = _fileModificationDate;
    return dictory.copy;
}

@end
